package com.tailyou.hms.neteasecloudmusic;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;

public class SplashActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash1);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                enterApp();
            }
        }, 3000);
    }

    /**
     * 从启动也进入App
     */
    private void enterApp() {
        //SharedPreference存储登录状态，如果已经登录，跳转到主界面，如果没有登录，跳转到登录界面
        SharedPreferences sharedPreferences = getSharedPreferences("app_config", MODE_PRIVATE);
        boolean isLogin = sharedPreferences.getBoolean("is_login", false);
        if (isLogin) {
            startActivity(new Intent(SplashActivity.this, MainActivity.class));
        } else {
            startActivity(new Intent(SplashActivity.this, LoginActivity.class));
        }
        finish();
    }
}